home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
VRML Browsing & Building Cyberspace
/
VRML - Browsing and Building Cyberspace.iso
/
examples
/
orrey.pl
< prev
next >
Wrap
Perl Script
|
1995-06-30
|
2KB
|
67 lines
#!/usr/bin/perl
#
# Sample Orrey program in PERL
# Written by Mark Pesce, June 1995
# No rights reserved.
#
# Let's do some time math.
#
# Get seconds since start of 1995.
# First get seconds as of 1 Jan 1995
# We cheated and precalculated this number.
# We cheated and got the number of seconds in a year, as well.
# Oh, alright, we did it for the seconds in a lunar month, too!
#
$yearZero = 788918400;
$secInYear = 31557600;
$secInLuMonth = 2514360;
$rightNow = time();
$sinceZero = $rightNow - $yearZero;
#print "There have been ", $sinceZero, " seconds since New Year GMT.\n";
$theSpin = ($sinceZero / $secInYear) * (3.1416 * 2);
#print "We are ", $theSpin, " through the year.\n";
#
# So now calculate x SIN and y COS values for Earth's position around the Sun
# The value of 20 is preserved from the original Translation node
#
$xVal = 20 * sin($theSpin);
$zVal = 20 * cos($theSpin);
#
$laLune = ($sinceZero / $secInLuMonth) * (3.1416 * 2);
$xMoon = 4 * sin($laLune);
$yMoon = 4 * cos($laLune);
#
# Always send the content type before everything else
#
print "Content-type: x-world/x-vrml\n\n";
#
# Then send the file header
#
print "#VRML V1.0 ascii\n";
#
# First, define the Sun.
#
print "Separator { Material { emissiveColor 1 1 0 } PointLight { intensity 1 color 1 1 0.9 } \n";
print "Sphere { radius 10 }\n";
#
# Next, the Earth.
#
print "Separator {\n";
print "Transform { translation ";
printf "%g %g 0 }\n", $xVal, $zVal;
print "Material { diffuseColor 0 0 1 specularColor 0.9 0.9 0.9 shininess 0.9 }\n";
print "Texture2 { filename \"http://hyperreal.com/~mpesce/WORLDMAP.RGB\" } Sphere { radius 2 }\n";
#
# Finally, the Moon.
#
print "Separator {\n";
print "Transform { translation ";
printf "%g %g 0 }\n", $xMoon, $yMoon;
print "Material { diffuseColor 0.7 0.7 0.7 shininess 0.3 } Texture2 { image 4 4 3\n";
print "0xC0C0C0 0x808080 0xFFFFFF 0x404040 0x808080 0x202020 0x808080 0xC0C0C0\n";
print "0x202020 0x808080 0xFFFFFF 0x808080 0x808080 0xC0C0C0 0x808080 0x202020 }\n";
print "Sphere { radius 1 } } } }\n";
#
# All done.
#